package com.openbravo.data.loader;

import com.openbravo.basic.BasicException;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;

public abstract class JDBCSentence extends BaseSentence
{
  protected Session m_s;

  public JDBCSentence(Session paramSession)
  {
    this.m_s = paramSession;
  }

  protected static final class JDBCDataResultSet
    implements DataResultSet
  {
    private ResultSet m_rs;
    private SerializerRead m_serread;

    public JDBCDataResultSet(ResultSet paramResultSet, SerializerRead paramSerializerRead)
    {
      this.m_rs = paramResultSet;
      this.m_serread = paramSerializerRead;
    }

    public Integer getInt(int paramInt)
      throws BasicException
    {
      try
      {
        int i = this.m_rs.getInt(paramInt);
        return this.m_rs.wasNull() ? null : new Integer(i);
      }
      catch (SQLException localSQLException)
      {  throw new BasicException(localSQLException);
      }
    
    }

    public String getString(int paramInt)
      throws BasicException
    {
      try
      {
        return this.m_rs.getString(paramInt);
      }
      catch (SQLException localSQLException)
      {throw new BasicException(localSQLException);
      }
      
    }

    public Double getDouble(int paramInt)
      throws BasicException
    {
      try
      {
        double d = this.m_rs.getDouble(paramInt);
        return this.m_rs.wasNull() ? null : new Double(d);
      }
      catch (SQLException localSQLException)
      {  throw new BasicException(localSQLException);
      }
    
    }

    public Boolean getBoolean(int paramInt)
      throws BasicException
    {
      try
      {
        boolean bool = this.m_rs.getBoolean(paramInt);
        return this.m_rs.wasNull() ? null : new Boolean(bool);
      }
      catch (SQLException localSQLException)
      { throw new BasicException(localSQLException);
      }
     
    }

    public Date getTimestamp(int paramInt)
      throws BasicException
    {
      try
      {
        Timestamp localTimestamp = this.m_rs.getTimestamp(paramInt);
        return localTimestamp == null ? null : new Date(localTimestamp.getTime());
      }
      catch (SQLException localSQLException)
      { throw new BasicException(localSQLException);
      }
     
    }

    public byte[] getBytes(int paramInt)
      throws BasicException
    {
      try
      {
        return this.m_rs.getBytes(paramInt);
      }
      catch (SQLException localSQLException)
      {  throw new BasicException(localSQLException);
      }
    
    }

    public Object getObject(int paramInt)
      throws BasicException
    {
      try
      {
        return this.m_rs.getObject(paramInt);
      }
      catch (SQLException localSQLException)
      {throw new BasicException(localSQLException);
      }
      
    }

    public DataField[] getDataField()
      throws BasicException
    {
      try
      {
        ResultSetMetaData localResultSetMetaData = this.m_rs.getMetaData();
        DataField[] arrayOfDataField = new DataField[localResultSetMetaData.getColumnCount()];
        for (int i = 0; i < arrayOfDataField.length; i++)
        {
          arrayOfDataField[i] = new DataField();
          arrayOfDataField[i].Name = localResultSetMetaData.getColumnName(i + 1);
          arrayOfDataField[i].Size = localResultSetMetaData.getColumnDisplaySize(i + 1);
          arrayOfDataField[i].Type = localResultSetMetaData.getColumnType(i + 1);
        }
        return arrayOfDataField;
      }
      catch (SQLException localSQLException)
      { throw new BasicException(localSQLException);
      }
     
    }

    public Object getCurrent()
      throws BasicException
    {
      return this.m_serread.readValues(this);
    }

    public boolean next()
      throws BasicException
    {
      try
      {
        return this.m_rs.next();
      }
      catch (SQLException localSQLException)
      { throw new BasicException(localSQLException);
      }
     
    }

    public void close()
      throws BasicException
    {
      try
      {
        this.m_rs.close();
      }
      catch (SQLException localSQLException)
      {
        throw new BasicException(localSQLException);
      }
    }

    public int updateCount()
      throws BasicException
    {
      return -1;
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.loader.JDBCSentence
 * JD-Core Version:    0.6.0
 */